package QiangHongBao;

import java.util.ArrayList;
import java.util.Random;

public class Manager {
    private String name;
    private int money;
    public Manager() {

    }
    public Manager(String name, int money) {
        this.name = name;
        this.money = money;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    @Override
    public String toString() {
        return "Manager{" +
                "name='" + name + '\'' +
                ", money=" + money +
                '}';
    }
    public ArrayList<Integer> send(int totalMoney, int count){
        ArrayList<Integer> red=new ArrayList<>();
        int leftMongy = this.getMoney();
        if(totalMoney>leftMongy){
            System.out.println("余额不足");
            return red;
        }
        Random random=new Random();
        int sy=totalMoney;
        for (int i=0;i<count;i++){
            if(i==count-1){
                red.add(sy);
                break;
            }
            int hb=random.nextInt(sy/(count-i)*2)+1;
            red.add(hb);
            sy=sy-hb;
        }
        return red;
    }
}
